<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorator="share/admin">

<head>
    <style type="text/css">

    </style>

</head>

<div layout:fragment="content">
    <form>
        <div id="tab-system" class="HuiTab">
            <!--<div class="tabBar cl"><span class="current">分类列表</span><span>上级分类</span></div>-->
            <div class="tabCon" style="display:block;padding-top:10px;">
                <table class="table table-border table-bordered table-hover table-bg table-sort" id="list">
                    <thead>
                    <tr>
                        <th style="width:70px;">ID</th>
                        <th>分类名</th>
                        <th>上级分类</th>
                        <th>路径</th>
                        <th>备注</th>
                        <th> 创建时间</th>
                        <th style="width:70px;text-align:center;"><a class="btn btn-primary radius" href="javascript:;" onclick="save()">添加</a> </th>
                    </tr>
                    </thead>
                </table>
            </div>

        </div>

    </form>
</div>
<script type="text/javascript" layout:fragment="scripts" th:inline="none">
    var tbSettings = $.extend($.datatablesSettings, {
                                  "sAjaxSource": "videoCate",
                                  "columns": [
                                      { "data": "id" },
                                      { "data": "name" },
                                      { "data": "parentId" },
                                      { "data": "parentIds" },
                                      { "data": "Remark" },
                                      { "data": "created" },
                                      { "data": "id", "sClass": "text-c f-18" }//操作按钮列
                                  ],
                                  "columnDefs": [{
                                      "targets": 5, "data": "Value", "render": function (data, type, full, meta) {
                                          return new Date(data).format('yyyy-MM-dd');
                                      }
                                  }, {
                                      "targets": 6, "render": function (data, type, row) {
                                          return '<a style="text-decoration:none" onclick="save(' + data + ');" href="javascript:;" title="编辑"><i class="Hui-iconfont"></i></a>\
                                                      <a class="ml-5" style="text-decoration:none" onclick="del('+ row.id + ');"  href="javascript:;" title="删除"><i class="Hui-iconfont"></i></a>';
                                      }
                                  },
                                      //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                                      { "orderable": false, "aTargets": [6] },// 制定列不参与排序
                                      { sDefaultContent: '', aTargets: ['_all'] }
                                  ], "fnServerParams": function (aoData) {
                                      //aoData.push({ "name": "real", "value": $(".tabBar .current").index() > 0 });
                                  }
                              });

    var tb = $('#list').dataTable(tbSettings);
    // tb.fnDraw();


    /*系统-栏目-添加*/
    function save(id) {
        var url = 'videoCate/save'+ (id? '/'+id:'');
        layer_show('编辑目录', url, '400', '350');
    }
    function del(id) {
        if (!confirm('确定删除吗？')) return;

        $lv.actionJson('videoCate/del?id='+id, function (r) {
            if (r && r.data>0) tb.fnDraw(true);
            else $lv.toast('删除失败！');
        });
    }
    $('.tabBar span').click(function () {
        if ($(this).hasClass('current')) return;
        $('.tabBar span').removeClass('current');
        $(this).addClass('current');
        tb.fnDraw();
    });
</script>